#include "OAMeetingRoom.h"
#include <iostream>
#include <string>

using namespace std;

OAMeetingRoom::OAMeetingRoom() {
  _mid = 0;
  _capacity = 0;
  _roomname = "";
  _roomtype = -1;
  _username = "";
}

OAMeetingRoom::OAMeetingRoom(int mid, int capacity, string roomname) {
  _mid = mid;
  _capacity = capacity;
  _roomname = roomname;
  _roomtype = -1;
  _username = "";
}

int OAMeetingRoom::mid() { return _mid; }

int OAMeetingRoom::capacity() { return _capacity; }

string OAMeetingRoom::roomname() { return _roomname; }

int OAMeetingRoom::roomtype() { return _roomtype; }

string OAMeetingRoom::roomtype_name() {
  if (_roomtype == 0) {
    return "已预约";
  } else if (_roomtype == 1) {
    return "会议中";
  } else if (_roomtype == 2) {
    return "维修中";
  }
  return "空闲";
}

string OAMeetingRoom::username() { return _username; }

/**
 * @brief 设置会议室状态
 *
 * @param roomtype
 * @return true
 * @return false
 */
bool OAMeetingRoom::roomtype(int roomtype, string username) {
  if (roomtype == -1) {
    // 在会议室在空闲中或者要设置的状态是空闲状态时才能设置会议室状态
    _roomtype = roomtype;
    _username = "";
    return true;
  } else if (_roomtype == -1) {
    // 在会议室空闲状态下才能设置会议室状态
    _roomtype = roomtype;
    _username = username;
    return true;
  } else if (_username == username) {
    _roomtype = roomtype;
    return true;
  }

  return false;
}